package com.liu.communitysystemend.module.memu.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.liu.communitysystemend.module.memu.domain.Menu;
import com.liu.communitysystemend.module.memu.service.MenuService;
import com.liu.communitysystemend.utils.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author liu
 * @create 2023-02-27 16:29
 */
@RestController
@RequestMapping("/api/menu")
public class MenuController {
    @Autowired
    private MenuService menMenuvice;

    @ApiOperation("添加菜单信息")
    @GetMapping("/get/{id}")
    public Result<Menu> getMenu(@PathVariable("id")String id){
        return menMenuvice.getMenuById(id);
    }

    @ApiOperation("更新菜单信息")
    @PostMapping("modify")
    public Result<Menu> save(@RequestBody Menu menu) {
        return menMenuvice.update(menu);
    }

    @ApiOperation("添加菜单信息")
    @PostMapping("add")
    public Result<Menu> add(@RequestBody Menu menu){
        return Result.success(menMenuvice.add(menu));
    }

    @ApiOperation("查询菜单列表(分页)")
    @PostMapping("page")
    public Result<Page<Menu>> getPage(@RequestBody Menu menu) {
        return Result.success(menMenuvice.getPage(menu));
    }

    @GetMapping("delete/{id}")
    @ApiOperation("删除菜单")
    public Result deleteById(@PathVariable("id") String id){
        return menMenuvice.deleteById(id)>0 ? Result.success():Result.failed();
    }

//    @PostMapping("list")
//    public Result<List<Menu>>




}